*********************************************************************************
*** Supplemental Material, Part A: Change in Relative Income of Young and Old ***
*********************************************************************************

*Figure A1 illustrates the average disposable income of individuals aged 25-34 (the young) and the average disposable income of individuals aged 65-74 (the old) relative to the national
*average over recent decades for Germany, Italy, Norway, Spain, U.K. and U.S. by using the Luxembourg Income Study Database (LIS). The LIS provides a set of cross-sectional
* datasets describing household and individual income and other characteristics for a large number of countries and years. These datasets have been harmonized to make variables 
*directly comparable across countries and years.
 
*While publicly available, the LIS data cannot be downloaded locally but can only be accessed remotely. The folder "Replication_Files_LRW/AppendixA" contains details instruction in the file "Code_LIS.txt". The instructions provide all the sequence of commands to remotely replicate the results based on LIS data. Data runs: 13/01/2024. 

clear all
use "Data_FigureA1.dta", replace 

rename v1 code_country
 
so code_country year

drop if year>2020

gen wave=.

by code_country, sort: replace wave=1975 if (year==1963|year==1964|year==1965|year==1966|year==1967|year==1968|year==1969|year==1970|year==1971|year==1972|year==1973|year==1974|year==1975|year==1976|year==1977)
by code_country, sort: replace wave=1980 if (year==1978|year==1979|year==1980|year==1981|year==1982)
by code_country, sort: replace wave=1985 if (year==1983|year==1984|year==1985|year==1986|year==1987)
by code_country, sort: replace wave=1990 if (year==1988|year==1989|year==1990|year==1991|year==1992)
by code_country, sort: replace wave=1995 if (year==1993|year==1994|year==1995|year==1996|year==1997)
by code_country, sort: replace wave=2000 if (year==1998|year==1999|year==2000|year==2001|year==2002)
by code_country, sort: replace wave=2004 if (year==2003|year==2004|year==2005)
by code_country, sort: replace wave=2007 if (year==2006|year==2007|year==2008)
by code_country, sort: replace wave=2010 if (year==2009|year==2010|year==2011)
by code_country, sort: replace wave=2013 if (year==2012|year==2013|year==2014)
by code_country, sort: replace wave=2016 if (year==2015|year==2016|year==2017)
by code_country, sort: replace wave=2019 if (year==2018|year==2019|year==2020)

by code_country wave, sort: egen mean_young = mean(reli2534)
by code_country wave, sort: egen mean_old = mean(reli6574)

twoway (connected mean_young wave if code_country==7, mcolor(black) msymbol(diamond) msize(small) lcolor(black)), ytitle("U.S.") ytitle(, size(medsmall) margin(medsmall)) ylabel(, labsize(medsmall)) || ///
       (connected mean_old wave if code_country==7, mcolor(gs8) msymbol(circle) msize(small) lcolor(gs8)), xtitle(Year) xtitle(, size(medsmall) margin(medsmall)) xlabel("1975 1980 1985 1990 1995 2000 2005 2010 2015 2020", labsize(medsmall)) legend(off) scheme(s1mono) saving(US, replace) 
	   
twoway (connected mean_young wave if code_country==1, mcolor(black) msymbol(diamond) msize(small) lcolor(black)), ytitle("Germany") ytitle(, size(medsmall) margin(medsmall)) ylabel(, labsize(medsmall)) || ///
       (connected mean_old wave if code_country==1, mcolor(gs8) msymbol(circle) msize(small) lcolor(gs8)), xtitle(Year) xtitle(, size(medsmall) margin(medsmall)) xlabel("1975 1980 1985 1990 1995 2000 2005 2010 2015 2020", labsize(medsmall)) legend(off) scheme(s1mono) saving(DE, replace)
 	     
twoway (connected mean_young wave if code_country==5, mcolor(black) msymbol(diamond) msize(small) lcolor(black)), ytitle("Norway") ytitle(, size(medsmall) margin(medsmall)) ylabel(, labsize(medsmall)) || ///
       (connected mean_old wave if code_country==5, mcolor(gs8) msymbol(circle) msize(small) lcolor(gs8)), xtitle(Year) xtitle(, size(medsmall) margin(medsmall)) xlabel("1980 1985 1990 1995 2000 2005 2010 2015 2020", labsize(medsmall)) legend(off) scheme(s1mono) saving(NO, replace)
	   
twoway (connected mean_young wave if code_country==3, mcolor(black) msymbol(diamond) msize(small) lcolor(black)), ytitle("Spain") ytitle(, size(medsmall) margin(medsmall)) ylabel(, labsize(medsmall)) || ///
       (connected mean_old wave if code_country==3, mcolor(gs8) msymbol(circle) msize(small) lcolor(gs8)), xtitle(Year) xtitle(, size(medsmall) margin(medsmall)) xlabel("1980 1985 1990 1995 2000 2005 2010 2015 2020", labsize(medsmall)) legend(off) scheme(s1mono) saving(SP, replace)
	   
twoway (connected mean_young wave if code_country==4, mcolor(black) msymbol(diamond) msize(small)  lcolor(black)), ytitle("Italy") ytitle(, size(medsmall) margin(medsmall)) ylabel(, labsize(medsmall)) || ///
       (connected mean_old wave if code_country==4, mcolor(gs8) msymbol(circle) msize(small) lcolor(gs8)), xtitle(Year) xtitle(, size(medsmall) margin(medsmall)) xlabel("1975 1980 1985 1990 1995 2000 2005 2010 2015 2020", labsize(medsmall)) legend(off) scheme(s1mono) saving(IT, replace)
	   
twoway (connected mean_young wave if code_country==6, mcolor(black) msymbol(diamond) msize(small) lcolor(black)), ytitle("U.K.") ytitle(, size(medsmall) margin(medsmall)) ylabel(, labsize(medsmall)) || ///
       (connected mean_old wave if code_country==6, mcolor(gs8) msymbol(circle) msize(small) lcolor(gs8)), xtitle(Year) xtitle(, size(medsmall) margin(medsmall)) xlabel("1975 1980 1985 1990 1995 2000 2005 2010 2015 2020", labsize(medsmall)) legend(off) scheme(s1mono) saving(UK, replace)
	   
	   
gr combine DE.gph IT.gph NO.gph SP.gph UK.gph US.gph , cols(3) ysize(3) xsize(7) graphregion(color(white)) plotregion(margin(zero)) 

